/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Objekte;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.logging.Level;
import logging.Logger;

/**
 * Einzelnes Produkt für die Autionsliste
 * @author benji
 */
public class AuctionProdukt {
    private int auctionid;
    private String product;
    private String person;
    private String highest_bidder = "";
    private int current_bid;
    private int amount;
    private String ttl;
    private Timestamp ende = null;

    public AuctionProdukt(int auctionid, int current_bid, int amount, Timestamp ende, String produkt, String anbietername) {
        this.auctionid = auctionid;
        this.current_bid = current_bid;
        this.amount = amount;
        this.ende = ende;
        this.current_bid = 0;
        this.person = anbietername;
        this.highest_bidder = "Noch kein Gebot";
        this.product = produkt;
        SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm", Locale.GERMANY);
        this.ttl = format.format(this.ende);
    }


    

    public AuctionProdukt(){
    }

    public int getAmount() {
        Logger.debug("AuctionProdukt - getAmount");
        return amount;
    }

    public void setAmount(int amount) {
        Logger.debug("AuctionProdukt - setAmount");
        this.amount = amount;
    }

    public int getAuctionid() {
        Logger.debug("AuctionProdukt - getAuctionID");
        return auctionid;
    }

    public void setAuctionid(int auctionid) {
        Logger.debug("AuctionProdukt - setAuctionID");
        this.auctionid = auctionid;
    }

    public int getCurrent_bid() {
        Logger.debug("AuctionProdukt - getCurrent_bid");
        return current_bid;
    }

    public void setCurrent_bid(int current_bid) {
        Logger.debug("AuctionProdukt - setCurrent_bid");
        this.current_bid = current_bid;
    }

    public String getHighest_bidder() {
        Logger.debug("AuctionProdukt - getHighest_Biddder");
        return highest_bidder;
    }

    public void setHighest_bidder(String highest_bidder) {
        Logger.debug("AuctionProdukt - setHighest_Biddder");
        this.highest_bidder = highest_bidder;
    }

    public String getPerson() {
        Logger.debug("AuctionProdukt - getPerson");
        return person;
    }

    public void setPerson(String person) {
        Logger.debug("AuctionProdukt - setPerson");
        this.person = person;
    }

    public String getProduct() {
        Logger.debug("AuctionProdukt - getProduct");
        return product;
    }

    public void setProduct(String product) {
        Logger.debug("AuctionProdukt - setProduct");
        this.product = product;
    }

    public String getTtl() {
        Logger.debug("AuctionProdukt - getTTL");
        return ttl;
    }

    public void setTtl(Timestamp ttl) {
        Logger.debug("AuctionProdukt - setTTL");
        this.ende =ttl;
        Date d = new Date(this.ende.getTime());
        SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm", Locale.GERMANY);
        this.ttl = format.format(this.ende);
    }

    public void setEnde(String ttl){
        Logger.debug("AuctionProdukt - setEnde mit String -- Parsen");
        SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm", Locale.GERMANY);
        this.ttl = format.format(ttl);
        try {
            this.ende = new Timestamp(format.parse(this.ttl).getTime());
        } catch (ParseException ex) {
            java.util.logging.Logger.getLogger(AuctionProdukt.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
  




}
